//
//  HYPhotoCollectionViewCell.m
//  XPlayer
//
//  Created by liguoqing on 2023/8/29.
//

#import "HYPhotoCollectionViewCell.h"

@interface HYPhotoCollectionViewCell ()

@property (nonatomic, strong) UIImageView *imageView;

@property (nonatomic, strong) UIView *bottomView;

@property (nonatomic, strong) UILabel *timeLabel;

@end

@implementation HYPhotoCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if(self){
        [self configUI];
    }
    return self;
}

- (void)configUI
{
    [self.contentView addSubview:self.imageView];
    [self.imageView addSubview:self.bottomView];
//    [self.bottomView addSubview:self.titleLabel];
    [self.bottomView addSubview:self.timeLabel];
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
    [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(self.imageView);
        make.height.mas_equalTo(20*KAdapterScale);
    }];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-5);
        make.centerY.equalTo(self.bottomView);
        make.height.mas_equalTo(20);
    }];
}

- (void)bindViewModel:(HYPhotoVideoItemViewModel *)vm
{
    _itemVm = vm;
    self.imageView.image = vm.videoImage;
    self.timeLabel.text = vm.videoDuration;
}

- (UIImageView *)imageView
{
    if(!_imageView){
        _imageView = [[UIImageView alloc]init];
        _imageView.contentMode = UIViewContentModeScaleAspectFill;
        _imageView.layer.cornerRadius = 2.0;
        _imageView.layer.masksToBounds = YES;
    }
    return _imageView;
}

- (UIView *)bottomView
{
    if(!_bottomView){
        _bottomView = [[UIView alloc]init];
        _bottomView.backgroundColor = [CommUtls colorWithHexString:@"#000000" Alpha:0.5];
    }
    return _bottomView;
}

- (UILabel *)timeLabel
{
    if(!_timeLabel){
        _timeLabel = [[UILabel alloc]init];
        _timeLabel.textColor = kWhiteColor;
        _timeLabel.font = FONT_SIZE(12);
    }
    return _timeLabel;
}

@end
